﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Contracts;

namespace ViewModel
{
    public class ContactViewModel : ApplicationViewModel
    {
        private bool edit = false;
        private List<string> groupList;
        public List<string> GroupList
        {
            get
            {
                return this.groupList;
            }
        }

        private Contact currentContact;
        public Contact CurrentContact 
        {
            get
            {
                if(this.currentContact == null)
                    this.currentContact = new Contact();
                return this.currentContact;
            }
            set
            {
                this.currentContact = value;
                this.edit = true;
            }
        }

        public ContactViewModel()
        {
            this.groupList = getModel.GetGroupList();
        }

        public bool AddContact(string mail, string alias, string group, bool blocked)
        {
            Contact theContact = new Contact()
                                     {
                                         Alias = alias,
                                         Blocked = blocked,
                                         Group = group,
                                         Mail = mail
                                     };
            if (this.edit)
                return this.getModel.EditContact(theContact);
            else
                return this.getModel.AddContact(theContact);
        }
    }
}
